#ifndef CFlash_COMP_H
#define CFlash_COMP_H

#define SYNC_VALUE 0x76C94D92
#define BLOCK_SIZE 1024


#pragma pack(1)
struct SIM_SimpleHeader
{
  unsigned int Magic_number;
  unsigned int Program_flags;
  unsigned int Number_of_Program_Bytes;
  unsigned short Version_Information;
};

struct SIM_DataRecord
{
  unsigned char Segment_type;
  unsigned short Record_flags;
  unsigned int Record_start_address;
  unsigned int Number_of_program_bytes;
};

struct SIM_EntryRecord
{
  unsigned int Entry_address;
  unsigned char Segment_type;
};

struct PHeader      //size=14
{
 unsigned int   ui_Sync;
 unsigned short us_OpCode;
 unsigned int   ui_CSum;
 unsigned int   ui_DataLen;
};

////////Data for transmitter packets///////
#define TINIT_OPCODE 1
struct TInit
{
 unsigned int ui_BasicAddr;
 unsigned int ui_FWareSize;
 unsigned int ui_BlockSize;
 unsigned int ui_BlockNums;
 //unsigned char uc_FWareType;
};

#define TBLOCK_OPCODE 2
struct TBlock                //size=
{
 unsigned int ui_BlockNum;
 char BData[1500];
};

#define TFLASH_OPCODE 3
struct TFlash
{
 unsigned int ui_FWareCSum;
 unsigned int ui_DataFlashAddr;
};
////////Data of packets from receiver ///////
#define ABLOCK_OPCODE 12
struct ABlock
{
 unsigned int ui_BlockNum;
 unsigned char uc_ErrCode;
};

#define AFLASH_OPCODE 13
struct AFlash
{
 unsigned int ui_BasicAddr;
 unsigned int ui_FWareSize;
 unsigned int ui_FWareCSum;
 unsigned int ui_ErrCode;
};


#pragma pack()

unsigned int Bytes_Swap(unsigned int int_var);



#endif
